package com.smcdd.cdb.dbo.cdb_dbo.ui.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.smcdd.cdb.dbo.cdb_dbo.R;
import com.smcdd.cdb.dbo.cdb_dbo.app.App;
import com.smcdd.cdb.dbo.cdb_dbo.service.presenter.CdbListInfoPresenter;
import com.smcdd.cdb.dbo.cdb_dbo.service.view.ICdbListInfoAc;
import com.smcdd.cdb.dbo.cdb_dbo.ui.base.BaseActivity;

/**
 * 作者：Administrator on 2017/6/22 14:11
 * 邮箱：zhanghuaiha@gmail.com
 * 所属设备
 */

public class CdbListInfoActivity extends BaseActivity<ICdbListInfoAc,CdbListInfoPresenter> implements ICdbListInfoAc {
    private RecyclerView mRecycler;
    private ImageView back;
    private TextView cdb_name;

    @Override
    public void initView() {
        mRecycler = (RecyclerView) findViewById(R.id.cdb_recycler);
        mRecycler.setLayoutManager(new LinearLayoutManager(this));
        back = (ImageView) findViewById(R.id.cdb_back);
        cdb_name = (TextView) findViewById(R.id.cdb_name);
    }

    @Override
    public void initData() {
        String sid = getIntent().getStringExtra("sid");
        String url = getIntent().getStringExtra("url");
        String name = getIntent().getStringExtra("name");
        cdb_name.setText(name);
        mPresenter.loadContacts(sid,url);
    }

    @Override
    public void initListener() {
        back.setOnClickListener(v -> finish());
    }

    @Override
    protected CdbListInfoPresenter createPresenter() {
        return new CdbListInfoPresenter(this);
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_cdb_list;
    }

    @Override
    public RecyclerView getRecycler() {
        return mRecycler;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.unLoadData();
    }
}
